/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.XmlDataBase;

import java.util.List;
import java.util.Set;
import org.w3c.dom.Document;

/**
 *
 * @author Viktor
 * 
 * In one medium, all the movies have to have DIFFERENT TITLE !!! (in real world too...)
 * In different mediums, you can have movie with the same title (in real world too)
 */
public interface MediumManager
{
    /**
     * Create medium in database
     * @param medium = medium to create
     * 
     * @throws DatabaseException
     * @throws NullPointerException
     * @throws IllegalArgumentException 
     */
    void createMedium(Medium medium) throws DatabaseException,NullPointerException,IllegalArgumentException;
    
    /**
     * Delete medium from database
     * @param id = id of medium to delete
     * 
     * @throws IllegalArgumentException
     * @throws NullPointerException
     * @throws DatabaseException 
     */
    void deleteMedium(String id) throws IllegalArgumentException,NullPointerException,DatabaseException;
    
    /** 
     * Update medium with all movies in database, use only by big changes in movies and medium's parameters.Need more time to execute !
     * @param medium = medium to update
     * 
     * @throws IllegalArgumentException
     * @throws NullPointerException
     * @throws DatabaseException 
     */  
    void updateMedium(Medium medium) throws IllegalArgumentException,NullPointerException,DatabaseException;
    
    /**
     * Get medium by id from database
     * @param id = medium's id
     * 
     * @return Medium if medium was found, else return null
     * 
     * @throws NullPointerException
     * @throws DatabaseException 
     */
    Medium getMediumById(String id) throws NullPointerException,DatabaseException;
    
    /**
     * Append movie to medium in database
     * 
     * @param medium
     * @param movie = movie to append
     * @throws NullPointerException
     * 
     * @throws IllegalArgumentException if medium already contains movie with the same title as movie's title
     * 
     * @throws DatabaseException 
     */
    void appendMovie(Medium medium, Movie movie) throws NullPointerException,IllegalArgumentException,DatabaseException;
    
    /**
     * Remove movie from medium in database
     * 
     * @param medium
     * @param movie = movie to remove from medium
     * @throws DatabaseException 
     * @throws IllegalArgumentException if movie is not in medium
     */
    void removeMovie(Medium medium, Movie movie) throws DatabaseException,IllegalArgumentException;
    
    /**
     * Return all medium's movies as Set 
     * @param medium
     * @return Set<Movie> if medium is in database, else return null!
     * @throws IllegalArgumentException 
     * @throws NullPointerException
     * @throws DatabaseException 
     */
    Set<Movie> getMediumsMovies(Medium medium) throws IllegalArgumentException,NullPointerException,DatabaseException;
    
    /**
     * Get all mediums ids in database
     * @return list of ids
     * @throws DatabaseException 
     */
    List<String> getAllMediumsIds() throws DatabaseException;
    
    /**
     * Get ids of all mediums, where the movie with specific title is stored
     * @param title = movie's title
     * @return medium's ids as list if movie is in database, else return null !
     * 
     * @throws DatabaseException
     * @throws IllegalArgumentException
     * @throws NullPointerException 
     */
    Set<String> getMediumsWithMovie(String title) throws DatabaseException,IllegalArgumentException,NullPointerException;
    
    /**
     * 
     * @param id
     * @return Document of type dom with medium, if medium not in database return null
     * @throws DatabaseException 
     */
    Document getMediumAsDom(String id) throws DatabaseException;
    
    /**
     * 
     * @param title
     * @return Document with movies by title, if movie with the title is not in database, return null
     * 
     * FORMAT OF DOM !!
     * <movies>
     *  <movie med_id="id of medium, where the movie is stored">
     *     Content equals scheme
     *  </movie>
     *  <movie>.....</movie>
     * </movies>
     * @throws DatabaseException 
     */
    Document getAllMoviesbyTitle(String title) throws DatabaseException;
}
